<template>
  <div>
    <el-menu router :collapse="isCollapse" :default-active="this.$route.path" class="el-menu-vertical-demo" style="min-height: 100%;" background-color="rgb(48,64,86)" text-color="#fff" active-text-color="#409EFF">
      <div style="height:60px;line-height:60px;text-align: center;">
        <img src="../assets/logo.png" alt="" style="width:20px;position: relative;top:5px;">
        <b style="color:#fff;margin-left: 5px;" v-show="isshow">后台管理系统</b>
      </div>
      <div v-for="item in menus" :key="item.id">
        <!-- 如果有path的话 就是一级菜单-->
        <div v-if="item.path">
          <el-menu-item :index="item.path">
            <i :class="item.icon"></i>
            <span slot="title" v-show="isshow">{{ item.name }}</span>
          </el-menu-item>
        </div>
        <!-- 有二级菜单的话 -->
        <div v-else>
          <el-submenu :index="item.id+''">
            <template slot="title">
              <i :class="item.icon"></i>
              <span v-show="isshow">{{ item.name }}</span>
            </template>
            <div v-for="subItem in item.children">
              <el-menu-item :index="subItem.path">
                <i :class="subItem.icon"></i>
                <span slot="title">{{ subItem.name }}</span>
              </el-menu-item>
            </div>
          </el-submenu>
        </div>
      </div>

    </el-menu>
  </div>
</template>

<script>
export default {
  name: 'Aside',
  props: {
    isCollapse: Boolean,
    isshow: Boolean,
  },
  data () {
    return {
      menus: localStorage.getItem("menus") ? JSON.parse(localStorage.getItem("menus")) : {},
    };
  },
  created () {

  },
  mounted () {

  },
  methods: {
  },
};
</script>

<style lang="less" scoped>
/*加快侧边栏文字消失的速度*/
.el-menu {
  transition: all 10ms;
}
.el-menu-item:hover {
  background-color: rgb(48, 64, 110) !important;
  border-radius: 10px;
}
/* 深选择器：如果相对设置了scoped的子组件里的元素进行控制可以使用'>>>'或者'deep'设置选中或悬浮的颜色*/
.el-submenu /deep/ .el-submenu__title:hover {
  background-color: rgb(48, 64, 110) !important;
  border-radius: 10px;
}
</style>